package S15.first;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

public class F02 {

	public static void main(String[] args) {
		List<Student>list=Arrays.asList(
			new Student("张三", 21, "水院"),
			new Student("李四", 21, "郑大"),
			new Student("王五", 19, "水院"),
			new Student("杨柳", 22, "河大"),
			new Student("赵琦", 22, "水院"),
			new Student("杨柳", 20, "水院")
		);
		System.out.println("所有的学生：");
		list.stream().forEach(s->System.out.println("\t"+s));
		System.out.println("获取水院的学生，按年龄降序排列，显示其姓名：");
		list.stream()
			.filter(s->s.getSchool().equals("水院"))
			.sorted(Comparator.comparingInt((Student s)->s.getAge()).reversed())
			.forEach(s->System.out.println("\t"+s));
		System.out.println("-----------------");
		list.stream()
			.filter(s->s.getSchool().equals("水院"))
			.sorted(Comparator.comparingInt(Student::getAge).reversed())
			.forEach(s->System.out.println("\t"+s));
		System.out.println("-----------------");
		list.stream()
			.filter(s->s.getSchool().equals("水院"))
			.sorted(Comparator.<Student>comparingInt(s->s.getAge()).reversed())
			.forEach(s->System.out.println("\t"+s));
	}

}
